package com.emergency.db.dao.item;

import com.emergency.db.domain.item.ItemLocation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface ItemLocationDao extends JpaRepository<ItemLocation, Long>, JpaSpecificationExecutor<ItemLocation> {
    @Modifying
    @Query(value = "delete FROM bas_item_location WHERE item_id = ? ", nativeQuery = true)
    void deleteAllByItem(Long id);

    @Query(value = "select * from bas_item_location where item_id = ?", nativeQuery = true)
    Page<ItemLocation> findAllByItem(Long id, Pageable p);
}
